{{ template "layout/header" .}}
<main id="body">
    <div class="container">
        <div class="btn-group mb-3 d-lg-none" role="group" id="my_mobile_nav">
            <a role="button" class="btn btn-secondary" data-active="menu-my" href="/my.html">个人资料</a>
            <a role="button" class="btn btn-secondary active" data-active="menu-my-thread"
                href="/my_thread.html">论坛帖子</a>
            <a role="button" class="btn btn-secondary" data-active="menu-my-notice" href="?my-notice.htm">消息</a>
        </div>
        <div class="row">
            <!-- 左侧菜单 -->
            <div class="col-lg-2 hidden-md hidden-sm" id="my_aside">
                <div class="card">
                    <div class="card-body text-center">
                        <img class="avatar-4" src="{{.sessions.Useravatar}}">
                        <br>{{.sessions.Username}}
                    </div>
                    <div class="list-group list-group-flush text-center">
                        <a href="/my.html" class="list-group-item list-group-item-action" data-active="menu-my">个人资料</a>
                        <a href="/my_thread.html" class="list-group-item list-group-item-action active"
                            data-active="menu-my-thread">论坛帖子</a>
                        <a href="?my-notice.htm" class="list-group-item list-group-item-action"
                            data-active="menu-my-notice">消息</a>
                    </div>
                </div>
            </div>
            <!-- 右侧内容 -->
            <div class="col-lg-10" id="my_main">
                <div class="card">
                    <div class="card-header">
                        <ul class="nav nav-tabs card-header-tabs">
                            <li class="nav-item">
                                <a class="nav-link" href="/my_thread.html" data-active="my-thread">主题</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link active" href="/my_favorite.html" data-active="my-favorite">收藏 </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="/my_digest.html" data-active="my-digest">精华</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="/my_post.html" data-active="my-post">帖子</a>
                            </li>
                        </ul>
                    </div>
                    <div class="card-body">
                        <ul class="list-unstyled threadlist mb-0">
                            {{range .threads}}
                            <li class="media thread tap top_3 " data-href="/thread/{{.ThreadID}}/detail.html"
                                data-tid="{{.ThreadID}}">
                                {{/*<input type="checkbox" name="modtid" class="mt-3 mr-2" value="{{.ThreadID}}">*/}}
                                <a href="/user/{{.User.ID}}/info.html" tabindex="-1" class="ml-1 mt-1 mr-3">
                                    <img class="avatar-3" src="{{.User.Avatar}}">
                                </a>
                                <div class="media-body">
                                    <div class="subject break-all">
                                        {{if .Thread.Top}}
                                        <i class="icon-top-{{.Thread.Top}}"></i>
                                        {{end}}
                                        <a href="/forum/{{.Thread.ForumID}}/list.html" target="_blank"
                                            title="{{.Thread.Forum.Name}}"
                                            class="text-grey">[{{.Thread.Forum.Name}}]</a>
                                        <a href="/thread/{{.ThreadID}}/detail.html"><span
                                                class="huux_thread_hlight_style1">{{.Thread.Subject}}</span></a>
                                    </div>
                                    <div class="d-flex justify-content-between small mt-1">
                                        <div>
                                            <span style="padding-bottom:0;margin-bottom:0;color:; ">
                                                <i class="iconfont icon-v1" style="font-size: !important;"></i>
                                            </span>
                                            <span class="username text-grey mr-1  hidden-sm"
                                                uid="{{.User.ID}}">{{.User.Username}}</span>
                                            <span
                                                class="date text-grey hidden-sm">{{.Thread.CreatedAt.Unix | strtime}}</span>
                                            {{/*<span>
                                                <span class="text-grey mx-2">←</span>
                                                <span class="username text-grey mr-1" uid="2">zhang</span>
                                                <span class="text-grey">3天前</span>
                                            </span>*/}}
                                            <span class="ml-3">
                                                <a href="javascript:;" onclick="myfavourite({{.ThreadID}})" title="移除收藏"
                                                    class="text-grey text-small js-haya-favorite-remove" data-tid="1">
                                                    <i class="icon-remove" aria-hidden="true"></i>
                                                    移除收藏 </a><a>
                                                </a></span><a>
                                            </a></div><a>
                                            <div class="text-muted small">
                                                <span class="ml-2"><i class="icon-eye"></i> {{.Thread.ViewsCnt}}</span>
                                                <span class="ml-2"><i class="icon-comment-o"></i>
                                                    {{.Thread.PostsCnt}}</span>
                                                <span class="ml-2" title="1 收藏">
                                                    <i class="icon-star-o" aria-hidden="true"></i>
                                                    {{.Thread.FavouriteCnt}}</span>
                                            </div>
                                        </a>
                                    </div><a>
                                    </a>
                                </div><a>
                                </a>
                            </li><a>
                            </a>
                            {{end}}
                        </ul><a>
                        </a>
                    </div><a>
                    </a>
                </div><a>
                </a>
            </div><a>
            </a>
        </div><a>
        </a>
    </div><a>
    </a>
</main>
<script>
    function myfavourite(tid) {
        console.log(tid);
        var fd = new FormData()
        fd.append("threadid", tid)
        $.ajax({
            url: "/api/v1/thread/" + tid + "/favourite",
            data: fd,
            type: "POST",
            contentType: false,
            processData: false,
            success: function (res) {
                //成功
                console.log(res)
                // return
                if (res.code == 200) {
                    $(".threadlist").find("li[data-tid=" + tid + "]").remove()
                } else {
                    $.alert(res.message)
                    return
                }
            }
        })
    }
</script>
{{ template "layout/footer" .}}
